package com.ntschy.common.core;

import com.ntschy.common.constant.HttpStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.List;

/**
 * @author ezreal_geng
 */

@Getter
@Setter
@ApiModel(description = "接口返回列表数据")
public class AjaxPageResult<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "业务状态码")
    private Integer code;

    @ApiModelProperty(value = "返回消息")
    private String msg;

    @ApiModelProperty(value = "数据对象")
    private List<T> data;

    @ApiModelProperty(value = "请求状态码")
    private boolean success;

    @ApiModelProperty(value = "分页数据")
    private PageData page;

    public AjaxPageResult() {
    }

    public AjaxPageResult(Integer code, String msg, List<T> data, boolean success, PageData page) {
        this.code = code;
        this.msg = msg;
        this.data = data;
        this.success = success;
        this.page = page;
    }

    public static <T> AjaxPageResult<T> success(List<T> data, PageData page) {
        return new AjaxPageResult<T>(HttpStatus.SUCCESS, "查询列表成功", data, true, page);
    }
}
